package com.sharemedia.vos
{
	import com.sharemedia.utils.RatingUtil;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public class Track extends EventDispatcher
	{
		public function Track(uid:String, fileName:String="", path:String="", likeNum:Number=0, unlikeNum:Number=0)
		{
			this.uid = uid;
			this.fileName = fileName;
			this.path = path;
			this.likeNum = likeNum;
			this.unlikeNum = unlikeNum;
		}
		
		[Bindable]
		public var broadcastUid:String;
		
		[Bindable]
		public var uid:String;
		
		[Bindable]
		public var info:TrackInfo;
		
		[Bindable]
		public var fileName:String;
		
		[Bindable]
		public var path:String; 
		
		private var _likeNum:Number; 

		[Bindable]
		public function get likeNum():Number
		{
			return _likeNum;
		}

		public function set likeNum(value:Number):void
		{
			_likeNum = value;
			calculateRating();
		}

		
		private var _unlikeNum:Number; 

		[Bindable]
		public function get unlikeNum():Number
		{
			return _unlikeNum;
		}

		public function set unlikeNum(value:Number):void
		{
			_unlikeNum = value;
			calculateRating();
		}

		
		private var _rating:Number; 

		[Bindable]
		public function get rating():Number
		{
			return _rating;
		}
		
		public function set rating(value:Number):void
		{
			_rating = value;
		}
		
		private function calculateRating():void
		{
			rating = RatingUtil.computeRating(likeNum, unlikeNum);
		}

		
		[Bindable]
		public var length:Number; 
		
		
		public var packets:Vector.<TrackPacket> = new Vector.<TrackPacket>();
	}
}